#!/usr/bin/python3
# coding=utf-8
# 查询公司信息目录
from pytdx.hq import TdxHq_API
from pytdx.params import TDXParams
import io
import sys
api = TdxHq_API()
argc=len(sys.argv)
code='002415'
if(argc>1):
    code=sys.argv[1]

if api.connect('119.147.212.81', 7709):
    data = api.get_company_info_category(TDXParams.MARKET_SZ, code)#返回一心堂公司信息目录
    data = api.to_df(data) # 返回DataFrame
    print(data)
    f = "../data/txt/"+code+".txt"
    data.to_csv(f, sep='\t',index=True, header = True)
    api.disconnect()